using JT808Protocol.Common;
using System;
using System.Text.Json.Serialization;

namespace JT808Protocol.Models.BodyParserStrategy.Location.LocationAddition
{
    /// <summary>
    /// 行驶记录功能获取的速度,0.1Km/h
    /// </summary>
    public class LaTachographSpeed_0x03 : ILocationAddition
    {
        /// <summary>
        /// 行驶记录功能获取的速度,0.1Km/h
        /// </summary>
        [JsonPropertyName("行驶记录功能获取的速度(0.1Km/h)")] public ushort TachographSpeed { get; set; }

        public override ILocationAddition ReadEntity(ReadOnlySpan<byte> source, int startIndex)
        {
            DataLength = (byte)(source[startIndex + 1] + 2);
            if (DataLength != 2 + 2)
            {
                //Logger.Warn($"位置附加信息的速度信息长度错误，略过解析");
                return null;
            }
            TachographSpeed = ParseHelper.Uint16(ref source, startIndex + 2);

            return this;
        }
    }
}